package com.cdtye.shuoh.domain.device.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cdtye.common.mybatiscore.base.BaseEntity;
import com.cdtye.shuoh.domain.enums.DeviceConnectStatus;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * 子设备档案表
 * @author ZhongWang Wang
 * @date 2022-12-21
 */
@ApiModel("子设备档案表")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("IOT_DEVICE_INFO")
public class DeviceInfo extends BaseEntity {
    
    @ApiModelProperty(value = "边设备档案主键")
    private String dId;

    @ApiModelProperty(value = "应用ID")
    private String appId;

    @ApiModelProperty(value = "设备节点ID")
    private String nodeId;

    @ApiModelProperty(value = "设备名称")
    private String nodeName;

    @ApiModelProperty(value = "子设备唯一标识")
    private String deviceId;

    @ApiModelProperty(value = "设备描述")
    private String description;

    @ApiModelProperty(value = "厂商ID")
    private String manufacturerId;

    @ApiModelProperty(value = "设备型号")
    private String model;

    @ApiModelProperty(value = "子设备连接状态 : 在线：ONLINE || 离线：OFFLINE || 未连接：INIT")
    private String connectStatus;

    @ApiModelProperty(value = "状态(字典值：0启用  1停用)")
    private String status;

    @ApiModelProperty(value = "归零值")
    private String benchmark;

    @ApiModelProperty(value = "备注")
    private String remark;

    @TableField(exist = false)
    private String deviceStatusName;

    @TableField(exist = false)
    private String deviceIdentification;

    @TableField(exist = false)
    private String connectStatusName;

    @TableField(exist = false)
    private String productIdentification;

    @TableField(exist = false)
    private String productName;

    @TableField(exist = false)
    private String deName;

    public String getDeviceStatusName(){
        if("1".equals(status)){
            return "启用";
        }
        return "禁用";
    }

    public String getConnectStatusName(){
        DeviceConnectStatus deviceConnectStatus = DeviceConnectStatus.parseByValue(connectStatus);
        if(null == deviceConnectStatus){
            return null;
        }
        return deviceConnectStatus.getTag();
    }


}